#pragma once

// CChatBaseDoc document
class RakPeerInterface;

class CChatBaseDoc : public CDocument
{
	RakPeerInterface*		m_pPeerInterface;

	DECLARE_DYNCREATE(CChatBaseDoc)

public:
	CChatBaseDoc();
	virtual ~CChatBaseDoc();
#ifndef _WIN32_WCE
	virtual void Serialize(CArchive& ar);   // overridden for document i/o
#endif
#ifdef _DEBUG
	virtual void AssertValid() const;
#ifndef _WIN32_WCE
	virtual void Dump(CDumpContext& dc) const;
#endif
#endif

protected:
	virtual BOOL OnNewDocument();

	DECLARE_MESSAGE_MAP()

public:
	virtual bool		StartUpRaknet(unsigned short maxConnections, int _threadSleepTimer, SocketDescriptor *socketDescriptors, unsigned socketDescriptorCount);
	virtual bool		Connect( const char* host, unsigned short remotePort);
	virtual Packet* 	Receive( void );
	virtual void		DeallocatePacket( Packet *packet );
	virtual uint32_t	Send( const RakNet::BitStream * bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast, uint32_t forceReceipt=0 );
	virtual uint32_t	Send( const char *data, const int length, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast, uint32_t forceReceipt=0 );
	virtual void		SetNetworkIDManager( NetworkIDManager *manager );
	void				AttachRaknetPlugin( PluginInterface2 *plugin );
	void				DetachRaknetPlugin( PluginInterface2 *plugin );
	void				CloseConnection( const SystemAddress& target);
	const RakNetGUID&	GetGuidFromSystemAddress( const SystemAddress& input ) const;
	SystemAddress		GetSystemAddressFromGuid( const RakNetGUID& input ) const;
};
